package com.tools.web.interceptor.auth;

import com.tools.common.object.Note;
import com.tools.common.thread.Timeunit;

/**
 * AuthToken 的接口规范
 * */
@Note("AuthToken 的接口规范")
public interface AuthToken {

    String getUuid();

    void setUuid(String uuid);

    Object getUserId();

    String stringUserId();

    long longUserId();

    int intUserId();

    void setUserId(Object userId);

    void setUserId(String userId);

    void setUserId(long userId);

    void setUserId(int userId);

    String getLoginDeviceType();

    void setLoginDeviceType(String loginDeviceType);

    void setLoginDeviceType(LoginDeviceType loginDeviceType);

    String getLoginUserType();

    void setLoginUserType(String loginUserType);

    long getLoginTimeMill();

    void setLoginTimeMill(long loginTime, Timeunit loginTimeunit);

    long getExpirationMill();

    void setExpirationMill(long expiration, Timeunit expirationTimeunit);

    int getExtendedCount();

    void setExtendedCount(int extendedCount);

    String encrypt();

    void decrypt(String encryptedToken);

    @Note("判断当前 AuthToken 是否已到期")
    default boolean isExpired() {
        return System.currentTimeMillis() >= this.getExpirationMill();
    }

    AuthToken uuid(String uuid);

    AuthToken userId(Object userId);

    AuthToken userId(String userId);

    AuthToken userId(long userId);

    AuthToken userId(int userId);

    AuthToken loginDeviceType(String loginDeviceType);

    AuthToken loginDeviceType(LoginDeviceType loginDeviceType);

    AuthToken loginUserType(String loginUserType);

    AuthToken loginTimeMill(long loginTime, Timeunit loginTimeunit);

    AuthToken expirationMill(long expiration, Timeunit expirationTimeunit);

    AuthToken extendedCount(int extendedCount);

}
